package com.vilen.weather.v_learn_firstcode.app.L_5;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.vilen.weather.v_learn_firstcode.app.BaseActivity;
import com.vilen.weather.v_learn_firstcode.app.ItemActivity;
import com.vilen.weather.v_learn_firstcode.app.R;

/**
 * Created by vilen on 2015/6/14.
 */
public class BroadcastBestPractice extends BaseActivity {
    private EditText accountEdit;
    private EditText passwordEdit;
    private Button login;

    public static void actionStart(Context context,String data1,String data2){
        Intent intent = new Intent(context,BroadcastBestPractice.class);
        intent.putExtra("data1",data1);
        intent.putExtra("data2",data2);
        context.startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        accountEdit = (EditText) findViewById(R.id.account);
        passwordEdit = (EditText) findViewById(R.id.password);
        login = (Button) findViewById(R.id.login);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String account = accountEdit.getText().toString().trim();
                String password = passwordEdit.getText().toString().trim();
                //如果是admin 和 123456.就认为登录成功
                if(account.equals("admin") && password.equals("123456")) {
                    Intent intent = new Intent(BroadcastBestPractice.this, OfflineActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Toast.makeText(BroadcastBestPractice.this,"account or password is invalid",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
